package com.itheima.mall.service.PmsService;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itheima.mall.commons.R;
import com.itheima.mall.mapper.PmsMapper.PmsBrandMapper;
import com.itheima.mall.service.pmsService.PmsBrandApi;
import com.itheima.pojo.pms.PmsBrand;
import org.apache.dubbo.config.annotation.DubboService;

import javax.annotation.Resource;
import java.util.List;

@DubboService
public class PmsBrandApiImpl implements PmsBrandApi {

    @Resource
    private PmsBrandMapper brandMapper;

    //添加品牌
    @Override
    public void addBrand(PmsBrand brand) {
        brandMapper.insert((PmsBrandMapper) brand);
    }

    @Override
    public List<PmsBrand> listAll() {
        return null;
    }
    //删除品牌
    @Override
    public void delete(Integer id) {
        brandMapper.deleteById(id);
    }

    //批量删除
    @Override
    public void deleteIds(List<Integer> ids) {
        brandMapper.deleteBatchIds(ids);

    }

    //修改品牌制造商状态
    @Override
    public void updateStatus(Integer factoryStatus, List<Long> ids) {

    }

    //修改是否更新显示状态
    @Override
    public void updateShowstatus(Integer showStatus, List<Long> ids) {

    }

    @Override
    public void updateBrand(PmsBrand brand) {
        brandMapper.updateById((PmsBrandMapper) brand);
    }

    @Override
    public PmsBrand findById(Long id) {
        return (PmsBrand) brandMapper.selectById(id);
    }

    @Override
    public R findBrand(Integer pageNum, Integer pageSize, String keyword) {
        Page<PmsBrand> pg = new Page<>(pageNum, pageSize);

        LambdaQueryWrapper<PmsBrand> wrapper = new LambdaQueryWrapper<>();
        wrapper.like(keyword != null, PmsBrand::getName, keyword);
        //return brandMapper.selectPage(pg, wrapper);
        return null;

    }
}
